import request from '@/utils/request.js'

export const deApproval = (processName,enterpriseId,creatorId,configData,type,processId) => {
    const requestBody = {
        processName,        // 对应 DTO 的 processName 字段
        enterpriseId,       // 对应 DTO 的 enterpriseId 字段
        creatorId,          // 对应 DTO 的 creatorId 字段
        configData,          // 根据 DTO 结构需要调整嵌套层级
        type,
        id:processId
    };
    return request.put('/process/definition',requestBody,
        { headers: { 'Content-Type': 'application/json' } }, );
};

export const getApprovals = (name,enterpriseId,pageNo,pageSize) => {
    return request.get('/process/getApprovals', {
        params: {
            name:name,
            enterpriseId : enterpriseId,
            pageNo,
            pageSize
        }
    });
};
export const updateStatusById = (id,status) => {
    const formData = new FormData();
    formData.append('id', id);
    formData.append('status', status);
    return request.patch('/process/updateStatusById',formData)
};
export const getConfigInfo = (id) => {
    return request.get('/process/getConfigInfo', {
        params: {
            id:id
        }
    });
};
export const getInstanceInfo = (instanceId,userName,pageNo,pageSize) => {
    const requestBody = {
        instanceId,
        userName,
        pageNo,
        pageSize
    };
    return request.put('/commonProcess/getInstanceInfo', requestBody);
};





